package org.dg.dgimg.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.dg.dgimg.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author DG
 * @since 2024-06-25
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT * FROM user WHERE user_mail = #{mail} AND user_password = #{password}")
    User selectUserByMailAndPassword(String mail, String password);

    //查询是否存在相同的邮箱名称
    @Select("SELECT COUNT(*) FROM user WHERE user_mail = #{mail}")
    int selectUserCountByMail(String mail);


    //新增一个用户
    @Insert("INSERT INTO user(user_name, user_password, user_mail) VALUES (#{userName},#{userPassword},#{userMail})")
    void insertUser(User user);
}
